<?php
/**
 * controller file Created by PhpStorm.
 * User: wumengmeng
 * Date: 2019/10/10
 * Time: 09:55
 */
 namespace Modules\Admin\Http\Controllers;

use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\Request;
use Modules\Admin\Service\YearCheckNoticeService;

class YearCheckNoticeController extends BaseController
{


    /**
     * 年检须知 列表
     *
     * @return array|\Illuminate\Contracts\View\Factory|\Illuminate\View\View
     * @author wumengmeng <wu_mengmeng@foxmail.com>
     */
    public function index()
    {
        try {
            $res = YearCheckNoticeService::get_all();
            echo_error($res);
            return view('admin::year_check_notice.index', $res);
        }
        catch (\Exception $exception) {
            return ['state'=>1,'msg'=>'失败','data'=>[],'error'=>$exception->getMessage()];
        }

    }

    /**
     * 添加 年检须知 页面
     *
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
     * @author wumengmeng <wu_mengmeng@foxmail.com>
     */
    public function create()
    {
        $n_cate = intval(Request::input('cate',0));
        $arr_data = ['n_cate'=>$n_cate];
        return view('admin::year_check_notice.create',$arr_data);
    }

    /**
     * 添加 年检须知 操作
     *
     * @return mixed
     * @author wumengmeng <wu_mengmeng@foxmail.com>
     */
    public function store()
    {
        $arr_input = Request::input();
        return YearCheckNoticeService::add_one($arr_input);
    }

    /**
     * 修改 年检须知 页面
     *
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
     * @author wumengmeng <wu_mengmeng@foxmail.com>
     */
    public function edit()
    {
        $nId = Request::get('id',0);
        $res = YearCheckNoticeService::get_one((int)$nId);
        echo_error($res);
        $arr_data = [
          'arr_data'=>$res['data'],
        ];
        return view('admin::year_check_notice.edit',$arr_data);
    }

    /**
     * 修改 年检须知 页面操作
     *
     *
     * @return array|\Illuminate\Http\RedirectResponse
     * @author wumengmeng <wu_mengmeng@foxmail.com>
     */
    public function update()
    {
        $arr_input = Request::input();
        return YearCheckNoticeService::edit_one($arr_input);
    }


    /**
     * 更改 年检须知 状态
     *
     * @return array|\Illuminate\Http\RedirectResponse
     * @author wumengmeng <wu_mengmeng@foxmail.com>
     */
    public function change_state()
    {
        $arr_input = Request::input();
        return YearCheckNoticeService::change_one_state($arr_input);
    }

    /**
     * 删除 年检须知
     *
     * @return array|\Illuminate\Http\RedirectResponse
     * @author wumengmeng <wu_mengmeng@foxmail.com>
     */
    public function delete()
    {
        $n_id = (int)Request::get('id',0);
        return YearCheckNoticeService::delete_one($n_id);
    }
}